//
//  MSThirdLayerFilterViewController.m
//  JYG_Agent
//
//  Created by apple on 15/10/19.
//  Copyright (c) 2015年 apple. All rights reserved.
//

#import "MSThirdLayerFilterViewController.h"

@interface MSThirdLayerFilterViewController ()

@end

@implementation MSThirdLayerFilterViewController
@synthesize dataArray;

-(void)setDataArray:(NSArray*)array
{
    dataArray=[[NSMutableArray alloc] initWithArray:array];
    [self.tableView reloadData];
    [self scrollToSelectedIndex];
}


-(void)scrollToSelectedIndex
{
    int index=0;
    for (int i=0;i<dataArray.count;i++)
    {
        NSObject* item=[dataArray objectAtIndex:i];
        if ([item isKindOfClass:[NSString class]])
        {
            if ([(NSString*)item isEqualToString:(NSString*)self.selected])
            {
                index=i;
            }
        }
    }
    [self.tableView scrollRectToVisible:CGRectMake(0, self.cellHeight*(index-1), APPFRAME.size.width, 280) animated:NO];
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString* indentifer=@"indentiferCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indentifer];
    if (cell==nil)
    {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentifer];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        cell.textLabel.font = [UIFont fontWithName:@"STHeitiSC-Light" size:15];
        cell.tintColor=kBlueColor;
    }
    
    cell.textLabel.text=[self.dataArray objectAtIndex:indexPath.row];
    if ([cell.textLabel.text isEqualToString:(NSString*)self.selected])
    {
        cell.textLabel.textColor=kBlueColor;
    }
    else
    {
        cell.textLabel.textColor=kDarkGrayColor;
    }
    
    cell.backgroundColor=[UIColor clearColor];
    cell.textLabel.backgroundColor=[UIColor clearColor];
    return cell;
}

@end
